package springboot.config;

import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springboot.interceptor.MyInterceptor;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Bean
    //注册拦截器
    public MyInterceptor myInterceptor(){
        return new MyInterceptor();
    }

    //添加拦截器至spring mvc 拦截器链

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor()).addPathPatterns("/*");
    }
}
